package com.web.kdl.controller.System;

import com.alibaba.fastjson.JSONObject;
import com.web.kdl.common.result.CommonResult;
import com.web.kdl.pojo.Vo.EnergyDataVo;
import com.web.kdl.pojo.Vo.SysEleVo;
import com.web.kdl.pojo.Vo.SysWorkStatusVo;
import com.web.kdl.pojo.Vo.SystemBaseVo;
import com.web.kdl.pojo.Vo.flywheel.FLywheelStatusVo;
import com.web.kdl.pojo.Vo.site.SiteBaseVo;
import com.web.kdl.pojo.Vo.site.SiteMonVo;
import com.web.kdl.service.site.SiteService;
import com.web.kdl.util.RedisKeyUtil;
import com.web.kdl.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author： shulibin
 * @Date： 2025/7/31 9:22
 * @Describe：
 */
@RestController
@RequestMapping("/Sys")
public class SystemController {
    @Autowired
    SiteService siteService;
    @Resource
    RedisUtils redisUtils;

    @Autowired
    // 获取系统信息
    @PostMapping("/getSystemInfo")
    @MessageMapping("/getSystemInfo")
    @SendTo("/response/getSystemInfo")
    public CommonResult<SystemBaseVo> getSystemInfo(){
        SystemBaseVo  systemBaseVo = siteService.getSystemInfo();

        return CommonResult.success(systemBaseVo);
    }

    // 获取系统当前工作状态 TODO 待定
    @PostMapping("/getSystemWorkStatus")
    @MessageMapping("/getSystemWorkStatus")
    @SendTo("/response/getSystemWorkStatus")
    public CommonResult<SysWorkStatusVo> getSystemWorkStatus(){
        SysWorkStatusVo siteStatusVo = siteService.getSystemWorkStatus();
        return CommonResult.success(siteStatusVo);
    }

    // 获取系统电量信息 全年 12月 未携带电量单位 kwh
    @PostMapping("/getSystemEleInfo")
    @MessageMapping("/getSystemEleInfo")
    @SendTo("/response/getSystemEleInfo")
    public CommonResult<List<EnergyDataVo>> getSystemEleInfo(){
       List<EnergyDataVo> sysEleVo =siteService.getSystemEleInfo();
        return CommonResult.success(sysEleVo);
    }

    // 系统信息--事件
    @PostMapping("/getSystemEvent")
    @MessageMapping("/getSystemEvent")
    @SendTo("/response/getSystemEvent")
    public CommonResult<List<SiteMonVo> > getSystemEvent(){
       List<SiteMonVo>   sysMonitorsVos= siteService.getSystemEvent();
        return CommonResult.success(sysMonitorsVos);
    }
}
